import { loginApi, loginImg } from '@/api/user'

const state = {
  token: null,
}

const mutations = {
  setToken(state, token) {
    state.token = token
  },
  deleteToken(state) {
    state.token = null
  },
}

// 封装 登录
const actions = {
  async loginApicotion({ commit }, data) {
    const res = await loginApi(data)
    // console.log(res);
    commit('setToken', res.data.token)
    return res
  }
}

export default {
  namespaced: true,
  mutations,
  state,
  actions,
}
